package JasPerl::JspApplicationContext;

use 5.010;
use strict;
use warnings;

use JasPerl::RequestDispatcher;
use JasPerl::Util::Enumeration;

sub new {
    my ($class, $config) = @_;
    bless { attrs => { }, config => $config }, $class;
}

sub get_attribute_names {
    return JasPerl::Util::Enumeration->from_list(keys %{$_[0]->{attrs}});
}

sub get_attribute {
    return $_[0]->{attrs}->{$_[1]};
}

sub set_attribute {
    if (defined $_[2]) {
        $_[0]->{attrs}->{$_[1]} = $_[2];
    } else {
        delete $_[0]->{attrs}->{$_[1]};
    }
}

sub remove_attribute {
    delete $_[0]->{attrs}->{$_[1]};
}

sub get_real_path {
    return $_[0]->{config}->get_real_path($_[1]);
}

sub get_request_dispatcher {
    return JasPerl::RequestDispatcher->new($_[0]->{config}, $_[1]);
}

1;
